<template>
  <view class="goBack" :style="{ top: tabHeight / 2 + 'px' }">
    <view>
      <i @click="onBack" >
        <view class="goBack-bgc">
          <uni-icons type="back" size="30" color="#fff"></uni-icons>
        </view>
      </i>
    </view> 
  </view>
</template>

<script setup>
import { ref } from "vue";
const menuButton = ref(uni.getMenuButtonBoundingClientRect());
const tabHeight = ref(+menuButton.value.top + menuButton.value.height + 20);

const onBack = () => {
  const pages = getCurrentPages();
  if (pages.length > 1) {
    uni.navigateBack();
  } else {
    uni.switchTab({ url: "/pages/index/index" });
  }
};
</script>

<style scoped>
.goBack {
  position: absolute;
  z-index: 1;
}
.goBack-bgc{
  margin-left: 40rpx;
  background-color: #999;
  padding: 5px;
  border-radius: 50%;
}
</style>
